//
//  UIFont+NewFont.m
//  WeiNingProject
//
//  Created by tianjians on 2018/10/12.
//  Copyright © 2018年 卫宁数据. All rights reserved.
//

#import "UIFont+NewFont.h"

@implementation UIFont (NewFont)

//+(void)load
//{
//    Method   changeMent = class_getClassMethod([self class], @selector(adjustFont:));
//    Method   systemMent = class_getClassMethod([self class], @selector(systemFontOfSize:));
//    method_exchangeImplementations(changeMent, systemMent);
//}
//
//
//
//+(UIFont *)adjustFont:(CGFloat)fontSize
//{
//    UIFont *newFont = nil;
////    if (IS_IPHONE_6){
////        newFont = [UIFont systemFontOfSize:fontSize];
////    } else if (IS_IPHONE_6_PLUS){
////        newFont = [UIFont systemFontOfSize:fontSize + 2];
////    } else if (IS_IPHONE_5){
////        newFont = [UIFont systemFontOfSize:fontSize-2];
////    } else {
//        newFont = [UIFont systemFontOfSize:fontSize + 1];
////    }
//    return newFont;
//}



+(UIFont *)newFontSize:(CGFloat)fontSize fontName:(NSString *)name
{
    UIFont *newFont=nil;
    CGFloat size = [[NSUserDefaults standardUserDefaults] floatForKey:@"fontSize"];
    
    if (IPHONE_6_PLUS){
        newFont = name.length == 0 ? [UIFont systemFontOfSize:fontSize + 2 + size] : [UIFont fontWithName:name size:fontSize + 2 + size];
    } else if (IPHONE_X){
        newFont = name.length == 0 ? [UIFont systemFontOfSize:fontSize + 1 + size] : [UIFont fontWithName:name size:fontSize + 1 + size];
    } else if (IPHONE_5){
        newFont = name.length == 0 ? [UIFont systemFontOfSize:fontSize -2 + size] : [UIFont fontWithName:name size:fontSize -2 + size] ;
    } else {
        newFont = name.length == 0 ? [UIFont systemFontOfSize:fontSize + size] : [UIFont fontWithName:name size:fontSize + size];
    }
    return newFont;
    
}

+(UIFont *)newFontSize:(CGFloat)size Weight:(UIFontWeight)weight
{

    
    UIFont *newFont=nil;

    
    if (IPHONE_6_PLUS){
        newFont = [UIFont systemFontOfSize:size + 2 weight:weight];;
    } else if (IPHONE_X){
        newFont = [UIFont systemFontOfSize:size + 1 weight:weight];;
    } else if (IPHONE_5){
        newFont = [UIFont systemFontOfSize:size - 2 weight:weight];;
    } else {
        newFont = [UIFont systemFontOfSize:size weight:weight];;
    }
    return newFont;
}

@end
